package com.qidian.by.cms.process;

import com.qidian.by.util.exceptions.ServiceExceptionEnum;
import com.qidian.by.util.pojo.EsResult;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;

/**
 * @Author: CoolPro
 * @Description:
 * @Time: 2024-05-07 09:39
 **/
@RestControllerAdvice(basePackages = "com.qidian.by.cms.controller")
public class CMSExceptionProcess {
    @ExceptionHandler(SQLIntegrityConstraintViolationException.class )
    @ResponseBody
    public EsResult handleCatMarkException(SQLIntegrityConstraintViolationException e) {
        if (e.getMessage().contains("buy_content_category.cat_mark")) {
            return EsResult.error(ServiceExceptionEnum.TYPE_MARK_REPEAT_ERROR);
        }
        return EsResult.error(ServiceExceptionEnum.PARAM_ERROR);
    }
}
